<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group(['namespace' => 'Api'], function () {
    Route::post('login', 'UserController@login'); //用户登陆
    Route::post('register', 'UserController@register'); //注册
    Route::post('send-code', 'UserController@sendCode'); //发送验证码
    Route::post('find-password', 'UserController@findPassword'); //找回密码

    Route::post('wechat-notify', 'ShoppingMallController@wechatNotify'); //微信支付异步通知

    Route::post('pickup-login', 'PickupUserController@login'); //核销端用户登陆
    Route::post('pickup-find-password', 'PickupUserController@findPassword'); //找回密码

});
Route::group(['middleware' => ['auth:api', 'check.user.status'], 'namespace' => 'Api'], function() {
    Route::post('evaluate', 'UserController@evaluate'); //评测
    Route::post('health-report', 'UserController@healthReport'); //健康报告
    Route::post('modify-password', 'UserController@modifyPassword'); //修改密码
    Route::post('user-info', 'UserController@getUserInfo'); //获取用户信息
    Route::post('user-logout', 'UserController@logout'); //退出登陆

    Route::post('user-diary', 'HealthDiaryController@index'); //健康日记
    Route::post('eat-analyse', 'HealthDiaryController@analyse'); //饮食分析
    Route::post('diary-record', 'HealthDiaryController@getDiaryRecord'); //获取日期

    Route::post('search-food', 'HealthEatController@searchFood'); //搜索食物
    Route::post('search-sport', 'HealthSportController@searchSport'); //搜索运动

    Route::post('health-eat', 'HealthEatController@index'); //获取饮食记录
    Route::post('add-eat', 'HealthEatController@addHealthEat'); //添加饮食记录
    Route::post('edit-eat', 'HealthEatController@editHealthEat'); //修改饮食记录
    Route::post('delete-eat', 'HealthEatController@DeleteHealthEat'); //删除饮食记录

    Route::post('health-sport', 'HealthSportController@index'); //获取饮食记录
    Route::post('add-sport', 'HealthSportController@addHealthSport'); //添加饮食记录
    Route::post('edit-sport', 'HealthSportController@editHealthSport'); //修改饮食记录
    Route::post('delete-sport', 'HealthSportController@DeleteHealthSport'); //删除饮食记录

    Route::post('health-drink', 'HealthDrinkController@index'); //获取喝水记录
    Route::post('edit-drink', 'HealthDrinkController@editHealthDrink'); //修改喝水记录

    Route::post('shopping-mall', 'ShoppingMallController@index'); //商城首页
    Route::post('goods-list', 'ShoppingMallController@goods'); //商品列表
    Route::post('goods-info', 'ShoppingMallController@goodsInfo'); //商品列表
    Route::post('add-to-cart', 'ShoppingMallController@addToCart'); //添加到购物车
    Route::post('cart-list', 'ShoppingMallController@cartList'); //购物车列表
    Route::post('dec-in-cart', 'ShoppingMallController@decInCart'); //减少购物车商品
    Route::post('delete-in-cart', 'ShoppingMallController@deleteInCart'); //删除购物车商品
    Route::post('get-cities', 'ShoppingMallController@getCities'); //获取城市
    Route::post('get-sites', 'ShoppingMallController@getPickupSites'); //获取自提点
    Route::post('confirm-order', 'ShoppingMallController@confirmOrder'); //确认订单
    Route::post('submit-order', 'ShoppingMallController@submitOrder'); //确认订单

    Route::post('order-list', 'ShoppingOrderController@index'); //订单列表
    Route::post('order-detail', 'ShoppingOrderController@detail'); //订单详情
    Route::post('order-pay', 'ShoppingOrderController@orderPay'); //订单支付
    Route::post('order-refund', 'ShoppingOrderController@applyRefund'); //订单申请退款
    Route::post('order-query', 'ShoppingMallController@orderQuery'); //微信支付异步通知

    Route::post('cookbook-list', 'CookBookController@index'); //食谱列表页
    Route::post('cookbook-detail', 'CookBookController@detail'); //食谱详情

    Route::post('ticket-detail', 'GymTicketController@detail'); //健身券详情
    Route::post('ticket-get', 'GymTicketController@get'); //健身券领取


});

Route::group(['middleware' => 'auth:api', 'namespace' => 'Api'], function() {
    Route::post('pickup-logout', 'PickupUserController@logout'); //核销端用户登陆
    Route::post('pickup-history', 'PickupUserController@checkHistory'); //核销端用户审核历史
    Route::post('pickup-check-order', 'PickupUserController@checkOrder'); //核销端用户核销
    Route::post('pickup-modify-password', 'PickupUserController@modifyPassword'); //核销端用户修改密码
});

Route::get('test', function () {
    return 'hello world';
});
Route::get('test', function (Request $request) {
	echo config("app.locale");
//	echo App::getFacadeAccessor();
	echo date('Y-m-d H:i:s');die;
	echo $request->input("id");
	echo $request->get("id");
	die;
	return var_export(App::environment('local'));
	
    return ['a','b'];
});
Route::post('test', function (Request $request) {
	if(empty($request['id'])){
		return 'null';
	}
    return $request['id'];
});

